<?php

if(isset($_REQUEST['memo'])) {
	$sql = sprintf("SELECT * FROM `t_memos` WHERE `memo_id` = %s",$_REQUEST['memo']);
	$result = mysql_query($sql);
	
	
	$message = mysql_fetch_assoc($result);
?>
		<div style="margin: 10px; ">
			<div style="font-size: 14px; font-weight:bold; border-bottom: 1px solid gray;"><h3>Memo</h3><span style="float:right;  font-size:11px; "><a href="#">DELETE</a></span></div>
			<table>
				<tr>
					<td style="font-weight:bold; ">From:</td>
					<td><?= driverName(-1)?></td>
				</tr>
				<tr>
					<td style="font-weight:bold; ">To:</td>
					<td><?= driverName($_SESSION['driver_id']) ?></td>
				</tr>
				<tr>
					<td style="font-weight:bold; ">Sent:</td>
					<td><?= date("D, M j, Y  H:i",strtotime($message['sent']))?></td>
				</tr>
				<tr>
					<td style="font-weight:bold; ">Subject:</td>
					<td><?= $message['subject'] ?></td>
				</tr>
			</table>
			<div style="padding: 10px; border-top: 1px solid gray; ">
			<?= $message['memo'] ?>
			</div>
		</div>
<?php
} else {
	$sql = sprintf("SELECT * FROM `t_messages` WHERE `message_id` = %s",$_REQUEST['msg']);
	$result = mysql_query($sql);
	$message = mysql_fetch_assoc($result);
?>
		<div style="margin: 10px; ">
			<div style="font-size: 14px; font-weight:bold; border-bottom: 1px solid gray;"><h3>Message</h3><span style="float:right;  font-size:11px; "><a href="#">DELETE</a></span></div>
			<table>
				<tr>
					<td style="font-weight:bold; ">From:</td>
					<td><?= driverName(-1)?></td>
				</tr>
				<tr>
					<td style="font-weight:bold; ">To:</td>
					<td><?= driverName($_SESSION['driver_id']) ?></td>
				</tr>
				<tr>
					<td style="font-weight:bold; ">Sent:</td>
					<td><?= date("D, M j, Y  H:i",strtotime($message['sent']))?></td>
				</tr>
				<tr>
					<td style="font-weight:bold; ">Subject:</td>
					<td><?= $message['subject'] ?></td>
				</tr>
			</table>
			<div style="padding: 10px; border-top: 1px solid gray; ">
			<?= $message['message'] ?>
			</div>
		</div>
<?php } ?>